# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=solvespace
pkgver=3.0
pkgrel=0
_dxtlibver=0b7b7b709d9299565db603f878214656ef5e9ddf
_solvespace_commit=0b7b7b709d9299565db603f878214656ef5e9ddf
_mimalloc_commit=4e643b6d3178e0ea2a093b7e14fe621631a91e4b
pkgdesc="A parametric 3D CAD program"
options="!check" # No testsuite
arch="all"
url="https://solvespace.com"
license="GPL-3.0-only"
makedepends="cmake glew-dev gtkmm3-dev pangomm2.48-dev json-c-dev"
subpackages="$pkgname-dev"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/solvespace/solvespace/archive/v$pkgver.tar.gz
	dtxlib-$_dxtlibver.tar.gz::https://github.com/solvespace/libdxfrw/archive/$_dxtlibver.tar.gz
	mimalloc-$_mimalloc_commit.tar.gz::https://github.com/microsoft/mimalloc/archive/$_mimalloc_commit.tar.gz
"

[ "$CARCH" = "riscv64" ] && options="textrels"

prepare() {
	default_prepare

	rm -r extlib/libdxfrw
	ln -s "$srcdir"/libdxfrw-$_dxtlibver extlib/libdxfrw
	rm -r extlib/mimalloc
	ln -s "$srcdir"/mimalloc-$_mimalloc_commit extlib/mimalloc

	sed -i CMakeLists.txt \
		-e 's/include(GetGitCommitHash)/#\0/g' \
		-e "s/# set(GIT_COMMIT_HASH.*/set(GIT_COMMIT_HASH $_solvespace_commit)/g"
	mkdir build
}

build() {
	cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib/"$pkgname" \
		-DCMAKE_BUILD_TYPE=None
	make
}

package() {
	cd build
	make DESTDIR="$pkgdir" install
}

sha512sums="
b07b41fac1d67c5350082600a2f09e3fa611a1273e0c93ff93d11a7a1dbf550ff33465686eaff04fdb8350d1fe854ab0301d8723ef31cc65c687ba59cb89187f  solvespace-3.0.tar.gz
9ab498aa7f369be79d800e8ca5ec55fa54be79d0778937b81d4c8da776b3419cb8a75400b54b205efc338da32e2e781afd0bed1bd8efed1a0b212dc8682a2615  dtxlib-0b7b7b709d9299565db603f878214656ef5e9ddf.tar.gz
6a64f3a46e1d02311f866ac996ba72d41ec6f8efa3c6844ea6fb5d7f52da0ab5397cd6ef8becc8d0155a938071a946895bd240b1a320dd868a1752bfecca24a7  mimalloc-4e643b6d3178e0ea2a093b7e14fe621631a91e4b.tar.gz
"
